package com.gtw.modules.api.controller;

import java.util.Map;
import com.baomidou.mybatisplus.plugins.Page;
import com.gtw.common.utils.Query;
import com.gtw.common.utils.R;
import com.gtw.modules.api.service.TbWalletpaylogService;
import com.gtw.modules.entity.TbWalletPayLog;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;


/**
 * 个人钱包记录表
 *
 * @author wuye
 * @email www.baidu.com
 * @date 2018-02-06 11:38:12
 */
@RestController
@RequestMapping("/api/walletpaylog")
public class TbWalletpaylogController {
    @Autowired
    private TbWalletpaylogService tbWalletpaylogService;


    /**
     * 查询列表
     * @param params
     * @returnapi
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        //查询列表数据
        Query query = new Query(params);
        Page<TbWalletPayLog> pageUtil = new Page<TbWalletPayLog>(query.getPage(), query.getLimit());
        Page<TbWalletPayLog> page = tbWalletpaylogService.queryPageList2(pageUtil,query);
        return R.ok().put("data", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info")
    public R info(Integer id) {
        TbWalletPayLog walletpaylog = tbWalletpaylogService.queryObject(id);

        return R.ok().put("walletpaylog", walletpaylog);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody TbWalletPayLog walletpaylog) {
        tbWalletpaylogService.save(walletpaylog);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody TbWalletPayLog walletpaylog) {
        tbWalletpaylogService.update(walletpaylog);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] ids) {
        for (int i = 0; i < ids.length; i++) {
            TbWalletPayLog tbWalletpaylog = tbWalletpaylogService.queryObject(ids[i]);
            tbWalletpaylog.setIddelete(true);
            tbWalletpaylogService.update(tbWalletpaylog);
        }

        return R.ok();
    }

}
